<div id="box-forum-groups">
    <div class="group-name"><a class="back" href="<?php echo $this->url()->getUrl('view/group/?id='.$this->forum['forum_group_id']) ?>" >Повернутись до списку форумів</a><?php echo ($this->forum['title']); ?></div>
	<table class="group-forum" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
            <th class="group-name">Теми</th>
            <th class="group-mesage">Повідомлення</th>
            <th class="group-mesage">Перегляди</th>
            <th class="group-lastmesage">Останнє повідомлення</th>
            </tr>
        </thead>
        <tbody>
        <?php if (count($this->ForumThreads)) { ?>
        <?php foreach($this->ForumThreads as $thread){ ?>
            <tr>
            	<td class="group-name"><a href="<?php echo $this->url()->getUrl('view/thread/?id='.$thread['id']) ?>"><?php echo $thread['title'];?></a><br/>
										<span class="date"><?php echo "Создан ".date("d.m.Y", $thread['created_on'] ) ?></span> </td>
    			<td class="group-mesage"><?php echo (( isset($this->ThreadsMessages[$thread['id']]) )?$this->ThreadsMessages[$thread['id']]:"--") ?></td>
    			<td class="group-mesage"><?php   ?></td>
    			<td class="group-lastmesage"><?php if( isset($this->ThreadsLastMessages[$thread['id']]) ){
    													if(isset($this->users[$this->ThreadsLastMessages[$thread['id']]['user_id']])){
    														echo $this->users[$this->ThreadsLastMessages[$thread['id']]['user_id']]['username'];
    													}else{
    														echo "привидение :)";
    													}
														echo "<br/>";
														echo "<span class='date'>".$this->date()->format($this->ThreadsLastMessages[$thread['id']]['date'])."</span>";
    												}else{
    													echo "--";
    												}
											  ?></td>
            </tr>		
        <?php }}  ?>
        </tbody>
	</table>
	<div>
		<input type="button" id="add_mass" value="Додати тему" />
	</div>
    
    <form action="<?php echo $this->url()->getUrl('thread/add/')?>" method="post">
	<table id="add" cellpadding="0" cellspacing="0" style="display: none;">
	    <thead>
            <tr>
            <th colspan="2">Нова тема</th>
            </tr>
        </thead>		
			<tr>
				<td class="lable">
					Назва
				</td>
				<td>
					<input type="text" name="thread[title]" id="mass_title"/>
				</td>
			</tr>
			<tr>
				<td>&nbsp;
				</td>
				<td>
					<input type="hidden" value="<?php echo ($this->forum['id']); ?>" name="thread[forum_id]" />
					<input type="submit" value="Додати"/>
					<input type="button" id="hideForm" value="Передумав"/>
				</td>
			</tr>	
	</table>
    </form>
</div>
